#!/bin/bash

echo "设置 /opt 目录结构..."

# 创建目录结构
mkdir -p debian/opt/kernel-management
mkdir -p debian/opt/kernel-management/bin
mkdir -p debian/opt/kernel-management/share
mkdir -p debian/opt/kernel-management/share/applications
mkdir -p debian/opt/kernel-management/share/icons/hicolor/48x48/apps

# 移动文件到新位置
if [ -d "debian/usr/share/kernel-management" ]; then
    mv debian/usr/share/kernel-management/* debian/opt/kernel-management/share/
fi

if [ -d "debian/usr/bin" ]; then
    mv debian/usr/bin/* debian/opt/kernel-management/bin/ 2>/dev/null || true
fi

# 移动桌面文件和图标
if [ -d "debian/usr/share/applications" ]; then
    mv debian/usr/share/applications/* debian/opt/kernel-management/share/applications/ 2>/dev/null || true
    rmdir debian/usr/share/applications 2>/dev/null || true
fi

if [ -d "debian/usr/share/icons" ]; then
    mv debian/usr/share/icons/* debian/opt/kernel-management/share/icons/ 2>/dev/null || true
    rmdir debian/usr/share/icons 2>/dev/null || true
fi

# 清理旧目录结构
rm -rf debian/usr/share
rmdir debian/usr/bin 2>/dev/null || true
rmdir debian/usr 2>/dev/null || true

echo "目录结构设置完成"